import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import * as ElIconModules from '@element-plus/icons-vue'

// 导入axios, 重新封装的axios
import axios from "./api/http";

const app = createApp(App)

app.use(ElementPlus)
for (let iconName in ElIconModules) {
    app.component(iconName, ElIconModules[iconName])
}
app.config.globalProperties.$http = axios;
app.use(router).mount('#app')


const debounce = (fn, delay) => {
    let timer = null;
    return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            fn.apply(context, args);
        }, delay);
    }
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 16);
        super(callback);
    }
}
